package com.winexpress.product;

import com.winexpress.entity.Category;
import com.winexpress.entity.Wine;
import com.winexpress.session.product.ProductSessionBean;
import java.util.List;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

@WebService(serviceName = "ProductManagementWS")
public class ProductManagementWS {

    @EJB
    private ProductSessionBean productSessionBean;

    @WebMethod(operationName = "addCategory")
    public boolean addCategory(@WebParam(name = "newCategory") Category c) {
        boolean flag = productSessionBean.addCategory(c);
        return flag;
    }

    @WebMethod(operationName = "addWine")
    public Long addWine(@WebParam(name = "newWine") Wine newWine) {
        Long id = productSessionBean.addWine(newWine);
        return id;
    }

    @WebMethod(operationName = "editWine")
    public boolean editWine(@WebParam(name = "editedWine") Wine editedWine) {
        boolean flag = productSessionBean.editWine(editedWine);
        return flag;
    }

    @WebMethod(operationName = "deleteCategory")
    public boolean deleteCategory(@WebParam(name = "categoryID") Long id) {
        return productSessionBean.deleteCategory(id);
    }

    @WebMethod(operationName = "deleteWine")
    public boolean deleteWine(@WebParam(name = "wineID") Long id) {
        return productSessionBean.deleteWine(id);
    }

    @WebMethod(operationName = "relistWine")
    public boolean relistWine(@WebParam(name = "wineID") Long id) {
        return productSessionBean.relistWine(id);
    }

    @WebMethod(operationName = "editCategory")
    public boolean editCategory(@WebParam(name = "editedCategory") Category editedCategory) {
        return productSessionBean.editCategory(editedCategory);
    }

    @WebMethod(operationName = "listCategory")
    public List<Category> listCategory() {
        List<Category> list = productSessionBean.listCategory();
        return list;
    }

    @WebMethod(operationName = "listWines")
    public List<Wine> listWines() {
        List<Wine> list = productSessionBean.listWines();
        return list;
    }

    @WebMethod(operationName = "listWinesForShop")
    public List<Wine> listWinesForShop() {
        List<Wine> list = productSessionBean.listWinesforShop();
        return list;
    }

    @WebMethod(operationName = "getWine")
    public Wine getWine(@WebParam(name = "id") long id) {
        return productSessionBean.getWine(id);
    }

    @WebMethod(operationName = "getCategory")
    public Category getCategory(@WebParam(name = "id") long id) {
        return productSessionBean.getCategory(id);
    }

    @WebMethod(operationName = "getAllCategories")
    public List<Category> getAllCategories() {
        return productSessionBean.getAllCategories();
    }

//    @WebMethod(operationName = "uploadImage")
//    public String uploadImage(String path, String name) {
//        return productSessionBean.UploadImage(path, name);
//    }

    @WebMethod(operationName = "findCategory")
    public Category findCategory(String windID) {
        return productSessionBean.findCategory(windID);
    }

    public List<Wine> returnCartItems(String sessionItems) {
        return productSessionBean.returnCartItems(sessionItems);
    }
}
